package com.sinacom.ibuilding.service;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ibatis.dao.client.DaoManager;
import com.sinacom.ibuilding.beans.Test;
import com.sinacom.ibuilding.dao.DaoConfig;
import com.sinacom.ibuilding.dao.iface.TestDao;

public class TestService {
	
	private TestDao testDao;
	public TestService(){
		DaoManager	daoManager = DaoConfig.getDaoManager();
		testDao = (TestDao) daoManager.getDao(TestDao.class);
	}
	
	public List getTestList(){
		Map map = new HashMap();
		return testDao.getTestList(map);
	}
	
	public void insertTest(Test test){
	    testDao.insetTest(test);
	}
	
	public static void main(String[] args) throws IOException{
		/*TestService testService = new TestService();
		TransActionService ts = new TransActionService();
		try {
            ts.startTransaction();
            Test test = new Test();
            test.setId("5");
            test.setName("测试5");
            testService.insertTest(test);
            
            
            Test test2 = new Test();
            test2.setId("6");
            test2.setName("测试6");
            testService.insertTest(test2);
           List list = testService.getTestList();
           for (int i = 0; i < list.size(); i++) {
               Test t = (Test) list.get(i);
               System.out.println(t.getName());
           }
            ts.commitTransAction();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            try {
                ts.endTransAction();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }*/
		
	 //   URL url = new URL("http://218.78.214.91:7001/corsms/Sendsms?oriadd=252&taradd=13564369099&content=justatest"); 
	    URL url = new URL("http://www.baidu.com");
	    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
	    BufferedReader reader = new BufferedReader(new InputStreamReader(
                connection.getInputStream()));
        System.out.println("=============================");
        System.out.println("Contents of get request");
        System.out.println("=============================");
        String lines;
        while ((lines = reader.readLine()) != null) {
            System.out.println(lines);
        }
        reader.close();
        // 断开连接
        connection.disconnect();
        System.out.println("=============================");
        System.out.println("Contents of get request ends");
        System.out.println("=============================");
	    
	}

}
